<template>
  <div class="blurry-loading">
    <div class="blurry-bg" :style="filter"></div>
    <div class="blurry-num" :style="opacity">{{ num }}%</div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 100,
    };
  },
  computed: {
    filter() {
      return {
        filter: `blur(${this.num / 5}px)`,
      };
    },
    opacity() {
      return {
        opacity: this.num / 50,
      };
    },
  },
  mounted() {
    this.timer = setInterval(() => {
      if (this.num <= 0) {
        clearInterval(this.timer);
        this.timer = null;
        return;
      }
      this.num--;
    }, 20);
  },
};
</script>
<style lang="scss" scoped>
.blurry-loading {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  .blurry-num {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
  }
  .blurry-bg {
    width: 100%;
    height: 100%;
    background: url("./image/bg1.webp") no-repeat center center/cover;
    background-size: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
    filter: blur(5px);
  }
}
</style>